package ma.ensao.evalmetrics.view;

import java.util.List;

import ma.ensao.evalmetrics.controller.UserManager;
import ma.ensao.evalmetrics.model.User;

import com.opensymphony.xwork2.ActionSupport;

/*
* Suppression des Users
*/
public class UserAction extends ActionSupport {

	private static final long serialVersionUID = 9149826260758390091L;
	private User user;
	private List<User> userList;
	private Long id;
    private UserManager linkController;
    private Long[] del;

	public Long[] getDel() {
		return del;
	}
	public void setDel(Long[] del) {
		this.del = del;
	}
	public UserAction() {
		linkController = new UserManager();
	}
	public String execute() {
		System.out.println("exec");
		this.userList = linkController.list();
		return SUCCESS;
	}
	public String liste() {
		try {
			System.out.println("UserAction liste");
			this.userList = linkController.list();	
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
	public String getSpecificUser() {
		System.out.println("UserAction getSpecificUser >>>>>>>>>>>>"+ getId());
		try {
			this.userList = linkController.getSpecificUser(getId());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}

	public String delete() {
		System.out.println(getId());
		linkController.delete(getId());
		return SUCCESS;
	}
	public String del() {
		System.out.println("del rows");
		for(Long s : del){
			linkController.delete(s);
    	}
		return SUCCESS;
	}
	public User getUser() {
		return user;
	}

	public List<User> getUserList() {
		return userList;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public void setuserList(List<User> userList) {
		this.userList = userList;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	public UserManager getLinkController() {
		return linkController;
	}
	public void setLinkController(UserManager linkController) {
		this.linkController = linkController;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public void setUserList(List<User> userList) {
		this.userList = userList;
	}
}
